# --! coding=utf-8 !--
# coding=utf-8
# Copyright (c) [2025] [2578713815@qq.com]
# [AHPU_EQM] is licensed under Mulan PSL v2.
"""
基本设置, 常量定义\n
author: <2578713815@qq.com>\n
"""

from os.path import join, dirname, abspath
from anti_useragent import UserAgent

BASE_DIR = dirname(dirname(abspath(__file__)))
'项目根目录'

SYS_DATA_PATH = join(BASE_DIR, 'CONFIG', 'SYS_DATA.json')
'''
系统设置文件\n
包含服务号,授权码,smpt服务器,端口号
'''

USERS_DATA_PATH = join(BASE_DIR, 'DB', 'USERS_DATA.csv')
'用户数据文件'

BUILDINGS_PATH = join(BASE_DIR, 'CONFIG', 'BUILDINGS.json')
'宿舍楼栋的id信息文件'

DATA_PATH = join(BASE_DIR, 'DB', 'DATA.csv')
'保存实时电量信息的csv文件'

LOG_PATH = join(BASE_DIR, 'DB', 'log.txt')
'日志文件'

CHECK_FILES = [SYS_DATA_PATH, USERS_DATA_PATH, BUILDINGS_PATH]
'主程序运行前需要提前检查的文件路径列表'

URL = "http://tysf.ahpu.edu.cn:8063/web/Common/Tsm.html"
'电量查询的目标路由'

HEADERS = {
	"User-Agent": UserAgent().random,
	"Accept": "application/json, text/javascript, */*; q=0.01",
	"Content-Type": "application/x-www-form-urlencoded; charset=UTF-8",
	"X-Requested-With": "XMLHttpRequest",
	"Origin": URL,
	"Referer": f"{URL}"
}
'检查电量的请求头'

ACCOUNT_LIST = ["52885", "60440"]
'可用的查询账号池'

TARGET_HOUR_1 = 6
'执行信息更新的时间点 小时'
TARGET_HOUR_2 = 18
'执行信息更新的时间点 小时'
TARGET_MINUTE = 0
'执行信息更新的时间点 分钟'
TARGET_SECONDS = 0
'执行信息更新的时间点 秒'

TOLERANCE_MINUTE = 2
'信息更新时间误差范围 分钟'
TOLERANCE_SECOND = 10
'信息更新时间误差范围 秒'

SUBJECT = "寝室电量提醒"
'邮件主题'
SENDER = "寝室电量余额监控助手"
'发送昵称'

RED = "\033[1;31m"
GREEN = "\033[1;32m"
YELLOW = "\033[1;33m"
BLUE = "\033[1;34m"
GRAY = "\033[1;37m"
RESET = "\033[0;0m"
'ANSI转义序列'

SEND_TIME_INTERVAL = 3
'消息发送间隔'
MODE_SEND_INTERVAL = 5
'不同模式之间的遍历间隔'

STATU_CODE = {
	0x000: GREEN + ">>> 发送成功" + RESET,
	0x001: GRAY + ">>> 当日信息已发送 跳过" + RESET,
	0x002: RED + ">>> 查询错误" + RESET,
	0x003: RED + ">>> 紧急阈值错误" + RESET,
	0x004: GRAY + ">>> 电量充足 不满足发送条件 跳过" + RESET,
	0x005: GRAY + ">>> 不在发送时间内 跳过" + RESET,
	0x006: RED + ">>> 发送失败" + RESET
}
'服务状态码与返回消息映射 '

INFO_HEADER = "[测试]"
INFO_BODY = "当前电量"
INFO_ENOUGH = "😊电量充足"
INFO_WARN = "😥电量不足 注意及时充电"
INFO_LIMIT = "😨电量告警 快断电啦"
